#pragma once

#include <qgraphicsview.h>
#include <qgraphicsscene.h>
#include <qgraphicsgridlayout.h>
#include <vector>
#include "ChannelWidget.h"

class ChannelView : public QGraphicsView
{
	Q_OBJECT

public:
	ChannelView(QWidget *parent = nullptr);
	~ChannelView();
	ChannelWidget* emplase_channel(const ChannelCreateInfo*);
protected:
	void mousePressEvent(QMouseEvent* event) override;
	void mouseReleaseEvent(QMouseEvent* event) override;
	void mouseMoveEvent(QMouseEvent* event) override;
	void resizeEvent(QResizeEvent* event) override;
public slots:
	void slot_remove_channel(ChannelWidget* chan);
	void slot_reset_layout();
signals:
	void showDetails(ChannelWidget*);

private:
	QPoint posAnchor;
	QPointF centerAnchor;
	Qt::MouseButton mouse_button;
	qreal max_z_value;
	QGraphicsScene sens;
	QGraphicsGridLayout layout;
	std::vector<std::pair<ChannelWidget*, QGraphicsProxyWidget*>> channels;
	QGraphicsItem* current_item;
	int pitch_count;
	int current_row;
	int current_col;
};
